﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DSA
{
    public class DSA_Row
    {
        //ATTRIBUTES

        private DSA_Product producto;
        private int quantity;
        private string p_name; //p_name is the attribute to define how the name of the product will be shown
        private string p_price; //p_price is the attribute to define how the price of the product will be shown
        private bool ticked_box;

        public string Name { get { return producto.Name; } set { producto.Name = value; } }
        public bool Ticked { get { return ticked_box; } }
        public double Price { get { return producto.Price; } set { producto.Price = value; } }
        public int Quantity { get { return quantity; } set { quantity = value; } }

        //CONSTRUCTOR
        public DSA_Row() : this(null, 0)
        {
            producto = new DSA_Product();
        }

        public DSA_Row(DSA_Product pr, int amount)
        {
            producto = pr;
            quantity = amount;
            p_name = FormatName();
            p_price = FormatPrice();
        }
      
        //PUBLIC METHODS

        public string FormatInfo() //It shows the string containing all the info of the product
        {
            //Here we describe how we want to show the product info (order: first the brand, after that the price...)
            //TBD
            if (!ticked_box)
            {
                return "F" + "\t" + FormatName() + "\t" + FormatQuantity() + "\t" + "$--" + "\t" + "--" + "\t" + "--";
            }
            else
            {
                return "T" + "\t" + FormatName() + "\t" + FormatQuantity() + " $" + FormatPrice() + "\t" + FormatBrand() + "\t" + FormatCategory();
            }
            
        }

        public void ToggleTick()
        {
            //Ticks this element box if it is unticked, or unticks it otherwise
            if (!ticked_box)
            
                ticked_box = true;
            else
                ticked_box = false;
        }


        //PRIVATE METHODS

        private string FormatName()
        {
            //TBD
            return producto.Name;
        }

        private string FormatPrice()
        {
            //TBD
            return producto.Price.ToString();
        }

        private string FormatBrand()
        {
            return producto.Brand;
        }

        private string FormatCategory()
        {
            return producto.Category;
        }

        private string FormatQuantity()
        {
            //TBD
            return quantity.ToString();
        }

    }
}
